<script setup lang="ts">
const props = defineProps({
  index: {
    type: Number, // 元素下标
    default: 0,
  },
  data: {
    type: Object,
    default: () => ({}),
  },
})
</script>

<template>
  <li class="item" ref="item">
    <div class="item__wrapper">
      <div class="item__info">
        <img :src="props.data.avatar" class="item__avatar" />
        <p class="item__name">{{ props.index }}. {{ props.data.name }}</p>
        <p class="item__date">{{ props.data.dob }}</p>
      </div>
      <p class="item__text">E-mail: {{ props.data.email }}</p>
      <p class="item__text">Phone: {{ props.data.phone }}</p>
      <p class="item__text">City: {{ props.data.address.city }}</p>
      <p class="item__text">Street: {{ props.data.address.street }}</p>
    </div>
  </li>
</template>

<style lang="scss" scoped>
.item {
  padding: 11px 20px;
  width: 100%;
  // height: 180px;
  &__wrapper {
    padding: 20px;
    padding-top: 0;
    background-color: #fff;
    border: 1px solid #eaeaea;
    border-radius: 5px;
  }
  &__info {
    padding: 20px 0 20px 60px;
    position: relative;
  }
  &__avatar {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    margin: auto 0;
    width: 50px;
    height: 50px;
    background-color: #eaeaea;
    border-radius: 100%;
    overflow: hidden;
  }
  &__name,
  &__date,
  &__text {
    margin-bottom: 4px;
    max-width: 100%;
    font-weight: bold;
    font-size: 12px;
    font-weight: normal;
  }
}
</style>
